﻿@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<link href="~/js/lay-module/flow/WaterFlow.css" rel="stylesheet" />
<link href="~/js/lay-module/formDesigner/formPreview.css" rel="stylesheet" />
<style type="text/css">
    div.layui-table-cell {
        color: rgb(102, 102, 102) !important;
    }
</style>
<script>
    //参数传递到表单页
    //表单数据
    var formtext;
    //只读参数
    var readonly = true;
    layui.use(['form', 'table', 'layer', 'element', 'jquery', 'waterflow', 'flowlayout', 'common', 'formPreview', 'layedit'], function () {
        var form = layui.form, element = layui.element,
            table = layui.table,
            layer = layui.layer,
            layedit = layui.layedit,
            common = layui.common,
            formPreview = layui.formPreview,
            $ = layui.jquery;
        var keyValue = $.request("keyValue");
        var flowDesignPanel;
        table.render({
            elem: '#mainList',
            page: false,
            url: '/FlowManage/Flowinstance/QueryHistories',
            where: { time: new Date().Format("yyyy-MM-dd hh:mm:ss") },
            cols: [[ //标题栏
                { field: 'Content', title: '流转记录', minWidth: 150 }
                , { field: 'CreatorUserName', title: '操作人', width: 150 }
                , {
                    field: 'CreatorTime', title: '创建时间', width: 180,
                    templet: function (d) {
                        if (d.CreatorTime) {
                            var time = new Date(d.CreatorTime);
                            return time.Format("yyyy-MM-dd hh:mm:ss");
                        }
                        return '';
                    }
                },
            ]]
            , where: {
                keyValue: keyValue
            }
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.state, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
        });
        $(function () {
            common.ajax({
                url: '/FlowManage/Flowinstance/GetFormJson',
                dataType: 'json',
                data: { keyValue: keyValue },
                async: false,
                success: function (data) {
                    var schemeContent = JSON.parse(data.SchemeContent);
                    if (!!data.CurrentMakerName) {
                        $('#CurrentMakerName').val(data.CurrentMakerName);
                    }
                    else {
                        $('#CurrentMakerName').parent().parent().remove();
                    }
                    flowDesignPanel = $('#flowPanel').flowdesign({
                        haveTool: false
                        , isprocessing: true
                        , activityId: data.ActivityId
                        , nodeData: schemeContent.nodes
                        , flowcontent: schemeContent
                    });
                    formtext = data.FrmData;
                    if (data.FrmType == 0) {
                        var dataJson = JSON.parse(data.FrmContent);
                        //表单设计器
                        var renderForm= formPreview.render({
                            data: dataJson,
                            elem: '#frmPreview',
                            readonly:true
                        });
                        renderForm.setFormData(JSON.parse(formtext));
                    }
                    else {
                        $("#frmPreview").load(document.location.origin + '/form/' + data.DbName + '.html');
                        form.render();
                    }
                    flowDesignPanel.reinitSize($(window).width() - 50, $(window).height() - 100);
                }
            });
        });
        $(window).resize(function () {
            flowDesignPanel.reinitSize($(window).width() - 50, $(window).height() - 100);
        });
        wcLoading.close();
        //让层自适应iframe
        //layer.iframeAuto(index);
    });
</script>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <div class="layui-form layuimini-form" lay-filter="adminform">
                <div class="layui-tab layui-tab-brief" lay-filter="tab" style="margin: 0px">
                    <ul class="layui-tab-title">
                        <li class="layui-this">流程信息</li>
                        <li>表单信息</li>
                    </ul>

                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">当前审核人</label>
                                <div class="layui-input-block">
                                    <input id="CurrentMakerName" name="CurrentMakerName" class="layui-input" disabled>
                                </div>
                            </div>
                            <table class="layui-table" id="mainList">
                            </table>
                            <div id="flowPanel"></div>
                        </div>

                        <div class="layui-tab-item">
                            <form class="layui-form layuimini-form">
                                <div class="layui-form-item">
                                    <fieldset class="layui-elem-field" style="padding-top:15px;">
                                        <div id="frmPreview"></div>
                                    </fieldset>
                                </div>
                            </form>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

